<template>
  <div class="music-container">
    <div class="background-wrapper"></div>
    <div class="content">
      <!-- 导航栏组件 -->
      <Navbar />

      <!-- AI音乐页面主要内容 -->
      <section class="music-main">
        <div class="music-content">
          <h2 class="page-title">AI音乐创作</h2>
          <p class="page-description">
            通过三步式精准定制流程，创作属于您的独特音乐作品
          </p>
          
          <!-- 创作步骤指示器 -->
          <div class="steps-indicator">
            <div 
              v-for="(step, index) in steps" 
              :key="index"
              :class="['step', { active: currentStep >= index, completed: currentStep > index }]"
            >
              <div class="step-number">{{ index + 1 }}</div>
              <div class="step-label">{{ step }}</div>
            </div>
          </div>
          
          <!-- 第一步：风格与情绪选择 -->
          <div v-show="currentStep === 0" class="creation-step">
            <h3>选择音乐风格与情绪</h3>
            <div class="selection-section">
              <div class="selection-group">
                <h4>音乐风格</h4>
                <div class="tags-container">
                  <div 
                    v-for="style in musicStyles" 
                    :key="style"
                    :class="['tag', { selected: selectedStyles.includes(style) }]"
                    @click="toggleStyle(style)"
                  >
                    {{ style }}
                  </div>
                </div>
              </div>
              
              <div class="selection-group">
                <h4>情绪标签</h4>
                <div class="tags-container">
                  <div 
                    v-for="mood in moods" 
                    :key="mood"
                    :class="['tag', { selected: selectedMoods.includes(mood) }]"
                    @click="toggleMood(mood)"
                  >
                    {{ mood }}
                  </div>
                </div>
              </div>
              
              <div class="selected-combination" v-if="selectedStyles.length || selectedMoods.length">
                <h4>已选组合：</h4>
                <div class="combination-tags">
                  <span v-for="style in selectedStyles" :key="style" class="combination-tag">{{ style }}</span>
                  <span v-for="mood in selectedMoods" :key="mood" class="combination-tag">{{ mood }}</span>
                </div>
              </div>
            </div>
            
            <div class="step-actions">
              <button class="next-btn" @click="nextStep" :disabled="!canProceedToStep1">下一步</button>
            </div>
          </div>
          
          <!-- 第二步：元素定制 -->
          <div v-show="currentStep === 1" class="creation-step">
            <h3>定制音乐元素</h3>
            <div class="customization-section">
              <div class="recommendation-section" v-if="recommendedElements.length">
                <h4>推荐元素（点击添加）</h4>
                <div class="tags-container">
                  <div 
                    v-for="element in recommendedElements" 
                    :key="element"
                    class="tag recommendation-tag"
                    @click="addElement(element)"
                  >
                    {{ element }}
                  </div>
                </div>
              </div>
              
              <div class="custom-input-section">
                <h4>自定义需求</h4>
                <textarea 
                  v-model="customDescription"
                  placeholder="请输入您的特殊需求，例如：加入雨声背景、时长3分钟、副歌旋律上扬等"
                  class="description-input"
                ></textarea>
                
                <div class="selected-elements" v-if="selectedElements.length">
                  <h4>已添加元素：</h4>
                  <div class="elements-container">
                    <span 
                      v-for="(element, index) in selectedElements" 
                      :key="index"
                      class="element-tag"
                    >
                      {{ element }}
                      <button class="remove-element" @click="removeElement(index)">×</button>
                    </span>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="step-actions">
              <button class="prev-btn" @click="prevStep">上一步</button>
              <button class="next-btn" @click="nextStep" :disabled="!canProceedToStep2">下一步</button>
            </div>
          </div>
          
          <!-- 第三步：参数设置与生成 -->
          <div v-show="currentStep === 2" class="creation-step">
            <h3>设置参数并生成音乐</h3>
            <div class="parameter-section">
              <div class="parameter-group">
                <h4>音乐时长</h4>
                <div class="radio-group">
                  <label v-for="duration in durations" :key="duration.value" class="radio-label">
                    <input 
                      type="radio" 
                      v-model="selectedDuration"
                      :value="duration.value"
                      name="duration"
                    >
                    {{ duration.label }}
                  </label>
                </div>
              </div>
              
              <div class="parameter-group">
                <h4>音质等级</h4>
                <div class="radio-group">
                  <label v-for="quality in qualities" :key="quality.value" class="radio-label">
                    <input 
                      type="radio" 
                      v-model="selectedQuality"
                      :value="quality.value"
                      name="quality"
                    >
                    {{ quality.label }}
                  </label>
                </div>
              </div>
              
              <div class="generation-summary">
                <h4>创作摘要</h4>
                <div class="summary-content">
                  <p><strong>风格组合：</strong>{{ selectedStyles.join(' + ') || '未选择' }}</p>
                  <p><strong>情绪标签：</strong>{{ selectedMoods.join(' + ') || '未选择' }}</p>
                  <p><strong>定制元素：</strong>{{ selectedElements.length ? selectedElements.join('、') : '无' }}</p>
                  <p><strong>自定义需求：</strong>{{ customDescription || '无' }}</p>
                  <p><strong>音乐时长：</strong>{{ selectedDuration }}分钟</p>
                  <p><strong>音质等级：</strong>{{ selectedQuality }}</p>
                </div>
              </div>
            </div>
            
            <div class="generation-actions">
              <button class="prev-btn" @click="prevStep">上一步</button>
              <button 
                class="generate-btn" 
                @click="generateMusic"
                :disabled="isGenerating"
              >
                {{ isGenerating ? '生成中...' : '生成音乐作品' }}
              </button>
            </div>
            
            <!-- 生成状态 -->
            <div v-if="isGenerating" class="generation-status">
              <div class="loading-spinner"></div>
              <p>正在为您创作音乐，请稍候...</p>
            </div>
            
            <!-- 音乐播放器 -->
            <div v-if="musicGenerated" class="player-section">
              <h3>我的音乐作品</h3>
              <div class="player-container">
                <div class="track-info">
                  <div class="track-artwork">🎵</div>
                  <div class="track-details">
                    <h4>AI创作音乐作品</h4>
                    <p>{{ generatedMusicTitle }}</p>
                  </div>
                </div>
                
                <div class="player-controls">
                  <button class="control-btn">⏮️</button>
                  <button class="control-btn play-btn" @click="togglePlay">
                    {{ isPlaying ? '⏸️' : '▶️' }}
                  </button>
                  <button class="control-btn">⏭️</button>
                </div>
                
                <div class="progress-container">
                  <div class="progress-bar">
                    <div class="progress" :style="{ width: progress + '%' }"></div>
                  </div>
                  <div class="time-info">
                    <span>{{ currentTime }}</span>
                    <span>{{ totalTime }}</span>
                  </div>
                </div>
                
                <div class="player-actions">
                  <button class="action-btn" @click="regenerateMusic">重新生成</button>
                  <button class="action-btn primary" @click="downloadMusic">下载</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- 底部 -->
      <footer class="footer">
        <p>© 2025 AI 艺术创作平台 - 让创意无界，让 AI 赋能艺术创作</p>
      </footer>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import Navbar from '../components/Navbar.vue'

const router = useRouter()

// 用户信息
const username = ref('')
const userInfo = ref<any>(null)

// 控制用户信息面板显示
const showUserProfile = ref(false)
// 用于延迟隐藏面板的定时器
const hideTimeout = ref<number | null>(null)

// 创作步骤
const currentStep = ref(0)
const steps = ref(['风格选择', '元素定制', '参数生成'])

// 音乐风格标签
const musicStyles = ref([
  '流行', '古典', '电子', '爵士', '国风', '摇滚', '民谣', '嘻哈',
  'R&B', '乡村', '蓝调', '金属', '朋克', '雷鬼', '拉丁', '新世纪'
])

// 情绪标签
const moods = ref([
  '欢快', '宁静', '激昂', '治愈', '忧郁', '梦幻', '紧张', '浪漫',
  '神秘', '孤独', '温暖', '激情', '轻松', '深沉', '优雅', '幽默'
])

// 选中的风格和情绪
const selectedStyles = ref<string[]>([])
const selectedMoods = ref<string[]>([])

// 推荐元素（根据选择的风格和情绪动态生成）
const recommendedElements = computed(() => {
  const recommendations: string[] = []
  
  // 根据风格推荐元素
  if (selectedStyles.value.includes('古典')) {
    recommendations.push('钢琴独奏', '小提琴伴奏', '管弦乐编排')
  }
  if (selectedStyles.value.includes('电子')) {
    recommendations.push('合成器音色', '节拍循环', '电子鼓组')
  }
  if (selectedStyles.value.includes('爵士')) {
    recommendations.push('萨克斯风', '即兴演奏', '复杂和声')
  }
  if (selectedStyles.value.includes('国风')) {
    recommendations.push('古筝', '笛子', '五声音阶')
  }
  if (selectedStyles.value.includes('摇滚')) {
    recommendations.push('电吉他失真', '强力和弦', '强劲鼓点')
  }
  
  // 根据情绪推荐元素
  if (selectedMoods.value.includes('欢快')) {
    recommendations.push('快节奏', '明亮音色', '跳跃旋律')
  }
  if (selectedMoods.value.includes('宁静')) {
    recommendations.push('慢节奏', '自然音效', '柔和音色')
  }
  if (selectedMoods.value.includes('激昂')) {
    recommendations.push('强烈节拍', '高潮部分', '动态变化')
  }
  if (selectedMoods.value.includes('治愈')) {
    recommendations.push('温暖和声', '舒缓旋律', '纯净音色')
  }
  
  return [...new Set(recommendations)] // 去重
})

// 自定义描述和选中的元素
const customDescription = ref('')
const selectedElements = ref<string[]>([])

// 参数设置
const durations = ref([
  { label: '1分钟', value: 1 },
  { label: '3分钟', value: 3 },
  { label: '5分钟', value: 5 }
])

const qualities = ref([
  { label: '标准', value: 'standard' },
  { label: '高清', value: 'hd' },
  { label: '无损', value: 'lossless' }
])

const selectedDuration = ref(3)
const selectedQuality = ref('hd')

// 生成状态
const isGenerating = ref(false)
const musicGenerated = ref(false)

// 播放器状态
const isPlaying = ref(false)
const progress = ref(30)
const currentTime = ref('1:15')
const totalTime = ref('3:45')
const generatedMusicTitle = ref('')

// 计算属性：是否可以进入下一步
const canProceedToStep1 = computed(() => {
  return selectedStyles.value.length > 0 || selectedMoods.value.length > 0
})

const canProceedToStep2 = computed(() => {
  return selectedElements.value.length > 0 || customDescription.value.trim() !== ''
})

// 切换风格标签
const toggleStyle = (style: string) => {
  const index = selectedStyles.value.indexOf(style)
  if (index > -1) {
    selectedStyles.value.splice(index, 1)
  } else {
    selectedStyles.value.push(style)
  }
}

// 切换情绪标签
const toggleMood = (mood: string) => {
  const index = selectedMoods.value.indexOf(mood)
  if (index > -1) {
    selectedMoods.value.splice(index, 1)
  } else {
    selectedMoods.value.push(mood)
  }
}

// 添加推荐元素
const addElement = (element: string) => {
  if (!selectedElements.value.includes(element)) {
    selectedElements.value.push(element)
  }
}

// 移除元素
const removeElement = (index: number) => {
  selectedElements.value.splice(index, 1)
}

// 下一步
const nextStep = () => {
  if (currentStep.value < 2) {
    currentStep.value++
  }
}

// 上一步
const prevStep = () => {
  if (currentStep.value > 0) {
    currentStep.value--
  }
}

// 生成音乐
const generateMusic = () => {
  isGenerating.value = true
  
  // 模拟生成过程
  setTimeout(() => {
    isGenerating.value = false
    musicGenerated.value = true
    generatedMusicTitle.value = `${selectedStyles.value.join('-')}${selectedMoods.value.join('-')}音乐`
    
    // 重置播放器状态
    isPlaying.value = false
    progress.value = 0
    currentTime.value = '0:00'
  }, 3000)
}

// 切换播放状态
const togglePlay = () => {
  isPlaying.value = !isPlaying.value
}

// 重新生成
const regenerateMusic = () => {
  musicGenerated.value = false
  generateMusic()
}

// 下载音乐
const downloadMusic = () => {
  alert('音乐下载功能已触发')
}

// 跳转到个人中心
const goToProfile = () => {
  router.push('/profile')
}

// 跳转到登录页
const goToLogin = () => {
  router.push('/')
}

// 处理登出
const handleLogout = async () => {
  try {
    // 清除本地用户信息
    localStorage.removeItem('userInfo')
    userInfo.value = null
    username.value = ''
    
    // 跳转到登录页
    router.push('/')
  } catch (error: any) {
    console.error('退出失败:', error)
    // 即使失败也清空本地信息并跳转到登录页
    localStorage.removeItem('userInfo')
    userInfo.value = null
    username.value = ''
    router.push('/')
  }
}

// 添加延迟隐藏功能
const startHideTimer = () => {
  if (hideTimeout.value) {
    clearTimeout(hideTimeout.value)
  }
  hideTimeout.value = window.setTimeout(() => {
    showUserProfile.value = false
    hideTimeout.value = null
  }, 300) // 300ms延迟
}

// 取消隐藏定时器
const cancelHideTimer = () => {
  if (hideTimeout.value) {
    clearTimeout(hideTimeout.value)
    hideTimeout.value = null
  }
}

// 组件挂载时加载用户信息
// 组件挂载时加载用户信息
onMounted(() => {
  const storedUserInfo = localStorage.getItem('userInfo')
  if (storedUserInfo) {
    try {
      userInfo.value = JSON.parse(storedUserInfo)
      username.value = userInfo.value.username || '用户'
    } catch (e) {
      console.error('解析用户信息失败:', e)
    }
  } else {
    // 如果没有用户信息，可能是从其他地方跳转过来的
    username.value = '用户'
  }
})

// 计算属性获取当前路由
const currentRoute = computed(() => router.currentRoute.value.path)

// 组件挂载时的初始化
onMounted(() => {
  console.log('AI音乐创作页面已加载')
})
</script>

<style scoped>
.music-container {
  position: relative;
  min-height: 100vh;
  width: 100vw;
}

.background-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #ffffff; /* 纯白色背景 */
  z-index: -1;
}

.content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* 导航栏样式 */
.navbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.nav-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo h1 {
  font-size: 24px;
  color: #667eea;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
}

.nav-links a {
  color: #333;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.3s;
  position: relative;
  padding: 8px 0;
}

.nav-links a:hover {
  color: #667eea;
}

.nav-links a.active {
  color: #667eea;
  font-weight: 600;
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #667eea;
  border-radius: 1px;
}

/* 下拉菜单 */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background: white;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  z-index: 1;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 0;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: #333;
  padding: 12px 24px;
  text-decoration: none;
  display: block;
  font-size: 14px;
  transition: all 0.3s;
}

.dropdown-content a:hover {
  background: #f5f5f5;
  color: #667eea;
}

.dropdown:hover .dropbtn {
  color: #667eea;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* 用户头像按钮样式 */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 用户信息悬浮面板 */
.user-profile-popup {
  position: absolute;
  top: 50px;
  right: 0;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
  margin-bottom: 12px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.profile-details {
  margin-bottom: 20px;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.profile-item:last-child {
  margin-bottom: 0;
}

.item-label {
  color: #666;
  font-size: 14px;
}

.item-value {
  color: #333;
  font-size: 14px;
  font-weight: 500;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-action-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.profile-action-btn:hover {
  background: #f5f5f5;
}

.profile-action-btn.logout {
  background: #fff5f5;
  color: #e53e3e;
}

.profile-action-btn.logout:hover {
  background: #ffebee;
}

.login-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  background: #667eea;
  color: white;
}

.login-btn:hover {
  background: #5568d3;
}

/* AI音乐页面主要内容 */
.music-main {
  width: 100vw;
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.music-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: #2D3E40;
  text-align: center;
  margin-bottom: 16px;
}

.page-description {
  font-size: 18px;
  color: #4A4A4A;
  text-align: center;
  margin-bottom: 40px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* 步骤指示器 */
.steps-indicator {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 50px;
  position: relative;
}

.steps-indicator::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 15%;
  right: 15%;
  height: 2px;
  background: #e0e0e0;
  z-index: 1;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.step-label {
  font-size: 16px;
  color: #999;
  font-weight: 500;
}

.step.active .step-number {
  background: #667eea;
  color: white;
}

.step.active .step-label {
  color: #667eea;
}

.step.completed .step-number {
  background: #4CAF50;
  color: white;
}

.step.completed .step-label {
  color: #4CAF50;
}

/* 创作步骤 */
.creation-step {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.creation-step h3 {
  font-size: 28px;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin-bottom: 30px;
}

/* 选择区域 */
.selection-section,
.customization-section,
.parameter-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.selection-group,
.recommendation-section,
.custom-input-section,
.parameter-group {
  margin-bottom: 30px;
}

.selection-group:last-child,
.recommendation-section:last-child,
.custom-input-section:last-child,
.parameter-group:last-child {
  margin-bottom: 0;
}

.selection-group h4,
.recommendation-section h4,
.custom-input-section h4,
.parameter-group h4 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.tag {
  background: #f0f0f0;
  color: #666;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.tag:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.tag.selected {
  background: #667eea;
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.recommendation-tag {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

.recommendation-tag:hover {
  background: rgba(102, 126, 234, 0.2);
}

.selected-combination,
.selected-elements {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed #e0e0e0;
}

.selected-combination h4,
.selected-elements h4 {
  margin-bottom: 15px;
}

.combination-tags,
.elements-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.combination-tag,
.element-tag {
  background: #667eea;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.remove-element {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  margin-left: 5px;
}

.description-input {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  resize: vertical;
  margin-bottom: 20px;
}

/* 参数设置 */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #333;
  cursor: pointer;
}

.radio-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.generation-summary {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.generation-summary h4 {
  margin-bottom: 15px;
}

.summary-content p {
  margin-bottom: 10px;
  font-size: 16px;
  color: #555;
}

.summary-content strong {
  color: #333;
}

/* 操作按钮 */
.step-actions,
.generation-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 30px;
}

.prev-btn,
.next-btn,
.generate-btn,
.action-btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.prev-btn,
.action-btn {
  background: #f5f5f5;
  color: #666;
}

.prev-btn:hover,
.action-btn:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.next-btn,
.generate-btn {
  background: #667eea;
  color: white;
}

.next-btn:hover,
.generate-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.next-btn:disabled,
.generate-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-btn.primary {
  background: #4CAF50;
  color: white;
}

.action-btn.primary:hover {
  background: #45a049;
}

/* 生成状态 */
.generation-status {
  text-align: center;
  padding: 30px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.generation-status p {
  font-size: 18px;
  color: #666;
}

/* 音乐播放器 */
.player-section {
  margin-top: 40px;
  animation: fadeIn 0.5s ease;
}

.player-section h3 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.player-container {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.track-info {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.track-artwork {
  font-size: 64px;
}

.track-details h4 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.track-details p {
  font-size: 16px;
  color: #666;
}

.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.control-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.control-btn:hover {
  background: #f0f0f0;
}

.play-btn {
  background: #667eea !important;
  color: white !important;
  font-size: 28px;
}

.play-btn:hover {
  background: #5568d3 !important;
}

.progress-container {
  margin-bottom: 20px;
}

.progress-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: #667eea;
  border-radius: 3px;
  transition: width 0.3s;
}

.time-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #666;
}

.player-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* 底部 */
.footer {
  background: #333;
  color: white;
  text-align: center;
  padding: 40px 24px;
  margin-top: 80px;
  width: 100%;
}

.footer p {
  font-size: 14px;
  opacity: 0.8;
}

/* 响应式 */
@media (max-width: 768px) {
  .steps-indicator {
    gap: 15px;
  }
  
  .steps-indicator::before {
    left: 10%;
    right: 10%;
  }
  
  .step-label {
    font-size: 14px;
  }
  
  .creation-step h3 {
    font-size: 24px;
  }
  
  .selection-section,
  .customization-section,
  .parameter-section {
    padding: 20px;
  }
  
  .tags-container {
    gap: 10px;
  }
  
  .tag {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  .radio-group {
    flex-direction: column;
    gap: 15px;
  }
  
  .step-actions,
  .generation-actions {
    flex-direction: column;
    gap: 15px;
  }
  
  .prev-btn,
  .next-btn,
  .generate-btn,
  .action-btn {
    width: 100%;
  }
  
  .player-container {
    padding: 20px;
  }
  
  .track-info {
    flex-direction: column;
    text-align: center;
  }
  
  .player-actions {
    flex-direction: column;
    gap: 15px;
  }
  
  .action-btn {
    width: 100%;
  }
}
</style>